home *** CD-ROM | disk | FTP | other *** search
/ Apple Service Training: …em Troubleshooting Course / Apple Service Training Macintosh Operating System Troubleshooting Course V1.0.iso / AppleScript Installer / AppleScript™ Setup 3 / Frontmost Samples / Dialog Server / Dialog Server Tester next >
Encoding:
Text File  |  1993-12-09  |  1.5 KB  |  41 lines  |  [TEXT/ToyS]

  1.  
  2. set myList to {"Bennet", "Brett", "Bruce", "Dan", "Dave", "Gary", "Ike", "James", "Jens", "Jon", "Ken", "Lee", "Mark", "Ron", "Scott", "Steve", "Sue", "Tom", "Warren", "William"}
  3. set myDefault to "" -- no item selected initially
  4. set myPrompt to "Give a bonus to which employee:"
  5. openDialogServer()
  6. set luckyOne to chooseOne(myPrompt, myList, myDefault)
  7. if luckyOne is "" then
  8.     display dialog "Sorry, no one was deemed worthy of a bonus." buttons "OK" default button 1
  9. else
  10.     set myPrompt to "How generous do you want to be with " & luckyOne & "?"
  11.     set myList to {"5¢", "$2.00", "$50.00", "$100.00", "$500.00", "$1000.00"}
  12.     set myDefault to "$100.00"
  13.     set bonusAmount to chooseOne(myPrompt, myList, myDefault)
  14.     if bonusAmount is "" then
  15.         display dialog "On second thought, there’s not enough cash to give out a bonus!" buttons "OK" default button 1
  16.     else
  17.         display dialog luckyOne & ", report to the boss for your " & bonusAmount & " bonus check!" buttons "OK" default button 1
  18.     end if
  19. end if
  20. closeDialogServer()
  21.  
  22. to openDialogServer()
  23.     tell application "Dialog Server.mini"
  24.         launch -- without sending a "run" message to the application
  25.     end tell
  26. end openDialogServer
  27.  
  28. to closeDialogServer()
  29.     tell application "Dialog Server.mini"
  30.         quit
  31.     end tell
  32. end closeDialogServer
  33.  
  34. to chooseOne(myPrompt, myList, myDefault)
  35.     tell application "Dialog Server.mini"
  36.         activate -- bring dialog server to the front
  37.         set selectedItem to listDialog(myPrompt, myList, myDefault)
  38.     end tell
  39.     activate current application -- return to our application (script editor)
  40.     return selectedItem
  41. end chooseOne